import request from '../utils/request';
import {config} from "md-editor-v3/lib/MdEditor/config";

const host_url = 'http://localhost:8081'
const openai_url = 'http://localhost:8090'

// 查询商品列表
export const queryProductList = (query:any) => {
    return request({
        url: `${openai_url}/api/v1/product/query`,
        params:query,
        method: 'get'
    });
};
// 编辑商品
export const editProduct = (data:any) => {
    console.log(JSON.stringify(data))
    return request({
        url: `${openai_url}/api/v1/product/edit`,
        headers: {
            'Content-Type': 'application/json'
        },
        data: JSON.stringify(data),
        method: 'post'
    });
};
// 删除商品
export const deleteProduct = (productId:number) => {
    return request({
        url: `${openai_url}/api/v1/product/delete?productId=${productId}`,
        method: 'delete'
    })
}
// 添加商品
export const addProduct = (data:any) => {
    console.log(JSON.stringify(data))
    return request({
        url: `${openai_url}/api/v1/product/add`,
        headers: {
            'Content-Type': 'application/json'
        },
        data: JSON.stringify(data),
        method: 'post'
    });
};


// 分页查询订单
export const queryOrderList = (query:any) => {
    return request({
        url: `${openai_url}/api/v1/order/query`,
        params:query,
        method: 'get'
    });
};

// 分页查询用户信息
export const queryUsersList = (query:any) => {
    return request({
        url: `${openai_url}/api/v1/user/query`,
        params:query,
        method: 'get'
    });
};
// 编辑用户信息
export const editUserInfo = (data:any) => {
    console.log(JSON.stringify(data))
    return request({
        url: `${openai_url}/api/v1/user/edit`,
        headers: {
            'Content-Type': 'application/json'
        },
        data: JSON.stringify(data),
        method: 'post'
    });
};

// 查询奖品列表（分页）
export const queryAwardList = (query:any) => {
    return request({
        url: `${host_url}/api/v1/award/queryAwardInfoLimitPage`,
        params:query,
        method: 'get'
    });
};
// 添加奖品
export const addAward = (data:any) => {
    console.log(JSON.stringify(data))
    return request({
        url: `${host_url}/api/v1/award/add`,
        headers: {
            'Content-Type': 'application/json'
        },
        data: JSON.stringify(data),
        method: 'post'
    });
};

// 查询策略列表（分页）
export const queryStrategyList = (query:any) => {
    return request({
        url: `${host_url}/api/v1/strategy/queryStrategyInfoLimitPage`,
        params:query,
        method: 'get'
    });
};

// 添加策略及策略明细
export const addStrategy = (data:any) => {
    console.log(JSON.stringify(data))
    return request({
        url: `${host_url}/api/v1/strategy/add`,
        headers: {
            'Content-Type': 'application/json'
        },
        data: JSON.stringify(data),
        method: 'post'
    });
};


// 查询策略明细
export const queryStrategyDetails = (query:any) => {
    return request({
        url: `${host_url}/api/v1/strategy/queryStrategyDetails`,
        params:query,
        method: 'get'
    });
};
// 查询策略配置
export const queryStrategyConfig = (query:any) => {
    return request({
        url: `${host_url}/api/v1/strategy/queryStrategyConfig`,
        params:query,
        method: 'get'
    });
};
// 分页查询用户中奖记录情况
export const queryStrategyExportList = (query:any) => {
    return request({
        url: `${host_url}/api/v1/strategy/queryStrategyExportList`,
        params:query,
        method: 'get'
    });
};


// 分页查询活动信息
export const queryActivityInfoLimitPage = (query:any) => {
    return request({
        url: `${host_url}/api/v1/activity/queryActivityInfoLimitPage`,
        params:query,
        method: 'get'
    });
};
// 添加活动
export const addActivity = (data:any) => {
    console.log(JSON.stringify(data))
    return request({
        url: `${host_url}/api/v1/activity/add`,
        headers: {
            'Content-Type': 'application/json'
        },
        data: JSON.stringify(data),
        method: 'post'
    });
};
// 编辑活动
export const editActivity = (data:any) => {
    console.log(JSON.stringify(data))
    return request({
        url: `${host_url}/api/v1/activity/edit`,
        headers: {
            'Content-Type': 'application/json'
        },
        data: JSON.stringify(data),
        method: 'post'
    });
};
// 删除活动
export const deleteActivity = (activityId:number) => {
    return request({
        url: `${host_url}/api/v1/activity/delete?activityId=${activityId}`,
        method: 'delete'
    })
}


// 获取转盘上的奖品数据
export const queryActivityAwardInfoListByJD = (activityId:number) => {
    return request({
        url: `${host_url}/api/v1/activity/queryPrizeListByJD?activityId=${activityId}`,
        method: 'get'
    });
};
// 触发转盘抽奖
export const doDrawExec = (query:any) => {
    return request({
        url: `${host_url}/api/v1/activity/doDrawExec`,
        params:query,
        method: 'get'
    });
};



// 删除策略
export const deleteStrategyRelate = (strategyId:number) => {
    return request({
        url: `${host_url}/api/v1/strategy/delete-relate?strategyId=${strategyId}`,
        method: 'delete'
    })
}

// 删除奖品
export const deleteAwardById = (awardId:number) => {
    return request({
        url: `${host_url}/api/v1/award/delete?awardId=${awardId}`,
        method: 'delete'
    })
}

// 编辑奖品
export const editAward = (data:any) => {
    console.log(JSON.stringify(data))
    return request({
        url: `${host_url}/api/v1/award/edit`,
        headers: {
            'Content-Type': 'application/json'
        },
        data: JSON.stringify(data),
        method: 'post'
    });
};